<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
    <title>Fluency Survey - Age</title>
    <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" />
    <style>
      body {
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
        background-color: #fff;
        color: #333;
      }

      .dark body {
        background-color: #1a1a1a;
        color: #f5f5f5;
      }

      /* Progress Bar Styles */
      .progress-container {
        height: 4px;
        width: 100%;
        background-color: #f0f0f0;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1000;
      }

      .progress-bar {
        height: 100%;
        background-color: #007aff;
        width: 12.5%; /* 8 steps, first step */
      }

      .dark .progress-container {
        background-color: #333;
      }

      /* Top Navigation */
      .top-nav {
        padding: 1rem;
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .back-btn {
        color: #007aff;
        font-size: 1.25rem;
        cursor: pointer;
      }

      /* Content Area */
      .content {
        max-width: 500px;
        margin: 0 auto;
        padding: 1rem;
      }

      /* Age Selection Cards */
      .age-card {
        padding: 1rem;
        border-radius: 12px;
        border: 1px solid #e5e7eb;
        margin-bottom: 1rem;
        cursor: pointer;
        transition: all 0.2s;
      }

      .age-card:hover,
      .age-card.selected {
        border-color: #007aff;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
      }

      .age-card.selected {
        background-color: rgba(0, 122, 255, 0.1);
      }

      .age-card .check-icon {
        opacity: 0;
        transition: opacity 0.2s;
      }

      .age-card.selected .check-icon {
        opacity: 1;
      }

      /* Button Styles */
      .btn-primary {
        background-color: #007aff;
        color: white;
        padding: 0.75rem 1.5rem;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
        display: inline-flex;
        align-items: center;
        width: 100%;
        justify-content: center;
        border: none;
      }

      .btn-primary:hover {
        background-color: #0062cc;
      }

      .btn-primary:disabled {
        background-color: #c7c7cc;
        cursor: not-allowed;
      }

      /* Dark Mode Adaptation */
      .dark .age-card {
        border-color: #4a5568;
        background-color: #2d3748;
      }

      .dark .age-card:hover,
      .dark .age-card.selected {
        border-color: #0a84ff;
      }

      .dark .age-card.selected {
        background-color: rgba(10, 132, 255, 0.2);
      }

      /* Theme Toggle Button */
      .theme-toggle {
        position: fixed;
        bottom: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        border-radius: 50%;
        background-color: #007aff;
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        z-index: 1000;
      }

      .theme-toggle:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
      }

      .nav-progress-container {
        display: flex;
        align-items: center;
        margin-bottom: 40px;
        gap: 15px;
      }

      .back-button {
        width: 30px;
        height: 30px;
        border: none;
        background: none;
        cursor: pointer;
        color: #2b85e4;
        font-size: 20px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
      }

      .back-button svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
      }

      .progress-bar {
        flex: 1;
        height: 6px;
        background-color: #e0e0e0;
        border-radius: 3px;
      }

      .progress {
        height: 100%;
        width: 3.33%;
        background-color: #2b85e4;
        border-radius: 3px;
      }
    </style>
    <script>
      // Check dark mode
      function checkDarkMode() {
        if (
          localStorage.getItem('darkMode') === 'true' ||
          (localStorage.getItem('darkMode') === null && window.matchMedia('(prefers-color-scheme: dark)').matches)
        ) {
          document.documentElement.classList.add('dark')
          return true
        }
        return false
      }

      // Toggle dark/light mode
      function toggleDarkMode() {
        if (document.documentElement.classList.contains('dark')) {
          document.documentElement.classList.remove('dark')
          localStorage.setItem('darkMode', 'false')
          document.getElementById('theme-icon').className = 'fas fa-moon'
        } else {
          document.documentElement.classList.add('dark')
          localStorage.setItem('darkMode', 'true')
          document.getElementById('theme-icon').className = 'fas fa-sun'
        }
      }

      // When DOM is loaded
      document.addEventListener('DOMContentLoaded', function () {
        const isDark = checkDarkMode()
        document.getElementById('theme-icon').className = isDark ? 'fas fa-sun' : 'fas fa-moon'

        // Handle age selection
        const ageCards = document.querySelectorAll('.age-card')
        const nextButton = document.getElementById('next-button')

        ageCards.forEach(card => {
          card.addEventListener('click', function () {
            // Remove selection from previous cards
            ageCards.forEach(c => c.classList.remove('selected'))
            // Select current card
            this.classList.add('selected')
            // Enable next button
            nextButton.disabled = false

            // Store selected age in localStorage
            const selectedAge = this.querySelector('span').textContent
            const pageTitle = document.querySelector('.text-3xl').textContent.trim()

            // Get current page name from URL
            const pageName = window.location.pathname.split('/').pop().split('.')[0]

            // Create data object
            const data = {
              title: pageTitle,
              value: selectedAge,
            }

            // Store as JSON in localStorage
            localStorage.setItem(pageName, JSON.stringify(data))
          })
        })
      })
    </script>
  </head>
  <body>
    <!-- Main Content Area -->
    <div class="content">
      <div class="nav-progress-container">
        <button class="back-button" onclick="window.location.href='/index.html'">
          <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
            <path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z" />
          </svg>
        </button>
        <div class="progress-bar">
          <div class="progress"></div>
        </div>
      </div>
      <!-- Page Title -->
      <div class="flex justify-center">
        <h1 class="w-80 text-3xl font-bold mb-6 text-center text-[#3BA0ff]">Discover Your English Potential</h1>
      </div>
      <div class="flex justify-center">
        <p class="w-96 text-center text-[#0B4983] font-semibold mb-6">
          Get your personalized learning plan tailored to your language goals.
        </p>
      </div>
      <p class="text-center text-[#0B4983] font-semibold mb-6">3 MINUTE QUIZ</p>
      <!-- Age Selection -->
      <div class="space-y-4 mb-8" id="next-button" onclick="window.location.href='/native_language.html'">
        <div class="age-card flex justify-between items-center">
          <span>18-24</span>
          <i class="fas fa-check text-blue-500 check-icon"></i>
        </div>
        <div class="age-card flex justify-between items-center">
          <span>25-34</span>
          <i class="fas fa-check text-blue-500 check-icon"></i>
        </div>
        <div class="age-card flex justify-between items-center">
          <span>35-44</span>
          <i class="fas fa-check text-blue-500 check-icon"></i>
        </div>
        <div class="age-card flex justify-between items-center">
          <span>45+</span>
          <i class="fas fa-check text-blue-500 check-icon"></i>
        </div>
      </div>
    </div>

    <!-- Theme Toggle Button -->
    <div class="theme-toggle" onclick="toggleDarkMode()">
      <i id="theme-icon" class="fas fa-moon"></i>
    </div>
  </body>
</html>
